/*******************************************************************************
 * Copyright (c) 2002 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 ******************************************************************************/
package net.sourceforge.perforce.core.internal.model;

import java.util.Date;

import net.sourceforge.perforce.core.api.IPerforceServer;
import net.sourceforge.perforce.core.model.IP4Label;

/**
  * @version $Revision: 216 $
  * @author  <a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class P4Label extends P4ModelObject implements IP4Label
{
	// --------------------------------------------------------------------------- Private Variables
	
	/** Stores the label. */
	private String label;
	/** Stores the date of last update. */
	private Date lastUpdate;
	/** Stores the date of last access. */
	private Date lastAccess;
	/** Stores the label's owner. */
	private String owner;
	/** Stores the description. */
	private String description;
	/** Indicates the lock state of the label. */
	private boolean locked;
	
	// ------------------------------------------------------------------------- Public Constructors
	
	/** Constructor for Label.
	  *
	  * @param theServer the perforce server.
	  * @param theLabel the label. 
	  */ 
	public P4Label(IPerforceServer theServer, String theLabel)
	{
		super(theServer);
	} 
	
	// ------------------------------------------------------------------------------ Public Methods

	/** @see IP4Label#getDescription() */		
	public String getDescription()
	{
		return description;
	}

	/** @see IP4Label#getLabel() */
	public String getLabel()
	{
		return label;
	}

	/** @see IP4Label#getLastAccess() */
	public Date getLastAccess()
	{
		return lastAccess;
	}

	/** @see IP4Label#getLastUpdate() */
	public Date getLastUpdate()
	{
		return lastUpdate;
	}

	/** @see IP4Label#isLocked() */
	public boolean isLocked()
	{
		return locked;
	}

	/** @see IP4Label#getOwner() */
	public String getOwner()
	{
		return owner;
	}

	/** Sets the description of the label.
	  * 
	  * @param newDescription The description to set
	  */
	public void setDescription(String newDescription)
	{
		description = newDescription;
	}

	/** Called to set the date of last access.
	  * 
	  * @param newLastAccess The lastAccess to set
	  */
	public void setLastAccess(Date newLastAccess)
	{
		lastAccess = newLastAccess;
	}
	
	/** Sets the date of the last update.
	  * 
	  * @param newLastUpdate The new last update value.
	  */
	public void setLastUpdate(Date newLastUpdate)
	{
		lastUpdate = newLastUpdate;
	}

	/** Changes the Label's lock state indicator.
	  * 
	  * @param newLocked true or false to indicate new lock state.
	  */
	public void setLocked(boolean newLocked)
	{
		locked = newLocked;
	}

	/** Sets the owner.
	  * 
	  * @param newOwner The new owner to set
	  */
	public void setOwner(String newOwner)
	{
		owner = newOwner;
	}
	
	/** @see java.lang.Object#toString() */
	public String toString()
	{
		return 
			"Label " + getLabel() +                                                    //$NON-NLS-1$
			" " + getLastUpdate() +                                                    //$NON-NLS-1$
			" '" + getDescription() + "'";                                             //$NON-NLS-1$
	}
}
